babl->class_type == BABL_FISH_SIMPLE)
{
long ret;
- long ticks = babl_ticks ();
+ /* long ticks = babl_ticks (); */
ret = babl_fish_process (babl, source, destination, n);
+ /* XX:
ticks -= babl_ticks ();
ticks *= -1L;
babl->fish.usecs += ticks;
babl->fish.processings++;
babl->fish.pixels += ret;
+ */
return ret;
}
return -1;
}
+#if BABL_DEBUG_MEM
+BablMutex *babl_debug_mutex;
+#endif
+
void
babl_internal_init (void)
{
babl_set_malloc (malloc);
babl_set_free (free);
+#if BABL_DEBUG_MEM
+ babl_debug_mutex = babl_mutex_new ();
+#endif
}
void
babl_internal_destroy (void)
{
+#if BABL_DEBUG_MEM
+ babl_mutex_destroy (babl_debug_mutex);
+#endif
}
#define BAI(ptr) ((BablAllocInfo *) *((void **) ptr - 1))
#define IS_BAI(ptr) (BAI (ptr)->signature == signature)
+#if BABL_DEBUG_MEM
+
/* runtime statistics: */
static int mallocs = 0;
static int frees = 0;
return buf;
}
+#endif
+
static void
functions_sanity (void)
{
*((void **) ret - 1) = ret - BABL_ALLOC - offset;
BAI (ret)->signature = signature;
BAI (ret)->size = size;
+#if BABL_DEBUG_MEM
+ babl_mutex_lock (babl_format_mutex);
mallocs++;
+ babl_mutex_unlock (babl_format_mutex);
+#endif
return (void *) (ret);
}
ret = babl_malloc (BAI (ptr)->size);
memcpy (ret, ptr, BAI (ptr)->size);
+#if BABL_DEBUG_MEM
+ babl_mutex_lock (babl_format_mutex);
dups++;
mallocs--;
+#endif
+ babl_mutex_unlock (babl_format_mutex);
return NULL;
}
{
BAI (format->image_template)->signature = NULL;
free_f (BAI (format->image_template));
+#if BABL_DEBUG_MEM
+ babl_mutex_lock (babl_format_mutex);
frees++;
+ babl_mutex_unlock (babl_format_mutex);
+#endif
}
format->image_template = NULL;
}
functions_sanity ();
BAI (ptr)->signature = NULL;
free_f (BAI (ptr));
+#if BABL_DEBUG_MEM
+ babl_mutex_lock (babl_format_mutex);
frees++;
+ babl_mutex_unlock (babl_format_mutex);
+#endif
}
/* reallocate allocation to be in size instead, contents of
#endif
memcpy (ret, ptr, babl_sizeof (ptr));
babl_free (ptr);
+#if BABL_DEBUG_MEM
+ babl_mutex_lock (babl_format_mutex);
reallocs++;
+ babl_mutex_unlock (babl_format_mutex);
+#endif
return ret;
}
memset (ret, 0, nmemb * size);
+#if BABL_DEBUG_MEM
+ babl_mutex_lock (babl_format_mutex);
callocs++;
mallocs--;
+ babl_mutex_unlock (babl_format_mutex);
+#endif
return ret;
}
babl_log ("args=(%s): failed", s);
strcpy (ret, s);
+#if BABL_DEBUG_MEM
+ babl_mutex_lock (babl_format_mutex);
strdups++;
mallocs--;
+ babl_mutex_unlock (babl_format_mutex);
+#endif
return ret;
}
return ret;
}
+#if BABL_DEBUG_MEM
/* performs a sanity check on memory, (checks if number of
* allocations and frees on babl memory evens out to zero).
*/
}
return 0;
}
+#endif